package cn.sdormitory.controller;

import cn.sdormitory.common.api.CommonResult;
import cn.sdormitory.morningExercises.vo.AppMorningExercisesCountVO;
import cn.sdormitory.morningExercises.vo.AppMorningExercisesToStuVO;
import cn.sdormitory.retention.AppRetentionCountVO;
import cn.sdormitory.retention.RetentionVO;
import cn.sdormitory.service.AppMorningExercisesService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : yy
 * @date: 2024/9/20 11:19
 * @description: 早操登记
 */
@RestController
@RequestMapping("/app/morningExercises")
public class AppMorningExercisesController {
    @Resource
    private AppMorningExercisesService exercisesService;

    @ApiOperation("教官查询当日早操登记名单")
    @GetMapping("/listTodayMorningExercises")
    public CommonResult<List<AppMorningExercisesToStuVO>> listTodayMorningExercises(){
        return CommonResult.success(exercisesService.listTodayMorningExercises());
    }

    @ApiOperation("当日早操登记")
    @GetMapping("/exercisesRegister")
    public CommonResult exercisesRegister(@RequestParam("studentId") Long studentId,
                                          @RequestParam("classId") Long classId,
                                          @RequestParam("type") Integer type,
                                          @RequestParam("registrantUser") String registrantUser){
        exercisesService.exercisesRegister(studentId,classId,type,registrantUser);
        return CommonResult.success();
    }


    @ApiOperation("删除早操登记记录")
    @GetMapping("/delMorningExercises")
    public CommonResult delMorningExercises(@RequestParam("id") Long id){
        exercisesService.delMorningExercises(id);
        return CommonResult.success();
    }

    @ApiOperation(value = "根据用户id查询早操登记统计信息-仅限班主任和部门经理使用")
    @GetMapping("/getAppMorningExercisesCount")
    public CommonResult<List<AppMorningExercisesCountVO>> getAppMorningExercisesCount(@RequestParam("userId") Long userId,
                                                                                      @RequestParam("rq") String rq) {
        return CommonResult.success(exercisesService.getAppMorningExercisesCount(userId,rq));
    }

    @ApiOperation(value = "根据班级id查询早操登记名单")
    @GetMapping("/getMorningExercisesStuByClassId")
    public CommonResult<List<AppMorningExercisesToStuVO>> getMorningExercisesStuByClassId(@RequestParam("classId") Long classId,
                                                                    @RequestParam("rq") String rq){
        List<AppMorningExercisesToStuVO> exercisesToStuVOS = exercisesService.getMorningExercisesStuByClassId(classId,rq);
        return CommonResult.success(exercisesToStuVOS);
    }

}
